<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" +
            request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/pintuer.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/admin.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/pintuer.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/admin.css">
    <link rel="shortcut icon" href="<%=basePath%>static/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="<%=basePath%>static/css/font.css">
    <link rel="stylesheet" href="<%=basePath%>static/css/xadmin.css">

<%--<script src="${pageContext.request.contextPath}/static/js/jquery.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/pintuer.js"></script>--%>
    <script src="<%=basePath%>static/js/jquery.js"></script>
    <script src="<%=basePath%>static/js/pintuer.js"></script>
    <script type="text/javascript" src="<%=basePath%>static/js/jquery-3.5.0.js">
    </script><script src="<%=basePath%>static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="<%=basePath%>static/js/xadmin.js"></script>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong><span class="icon-key"></span> 修改密码</strong></div>
        <form action="" method="post" class="layui-form">
            <input name="username" placeholder="用户名" id="username"  type="reset" class="layui-input" value="${username}" >
            <hr class="hr15">
            <input name="pwd" placeholder="密码" id="pwd"  type="password" class="layui-input">
            <hr class="hr15">
            <input type="password" class="layui-input" name="newPass" id="newPass" size="50" placeholder="请输入新密码"/>
            <hr class="hr15">
            <input type="password" class="layui-input" name="renewPass" id="renewPass" size="50" placeholder="请再次输入新密码"/>
            <hr class="hr15">
            <input value="提交" style="width:100%;" type="button" onclick="aa()">
            <hr class="hr20" >
        </form>
    </div>
</div>
<script>
    // selectAllUser
    function aa() {
        // ajax请求
        $.ajax({
            // 请求服务器的路径
            url: "../admin/update",
            // 提交方式
            type: "post",
            // 服务器响应数据类型
            dataType: "json",
            // 发送给服务器的数据内容
            data: {
                "username":$("#username").val(),
                "pwd": $("#pwd").val(),
                "newPass":$("#newPass").val(),
                "renewPass":$("#renewPass").val(),
            },//成功回调函数
            success: function (data) {
                // 获取用户数据
                if(data.code == 200){
                    alert("修改成功,返回登录界面")
                    parent.location.href = '../sys/returnLogin';
                }else {
                    alert(data.updateInfo);
                }
            },// 失败回调
            error: function () {
                alert("服务器错误");
            }
        })
    }


</script>
</body>
</html>
